package cate.game.play.buff.h;

import cate.common.table.d.GDSkill;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import easy.java.struct.ref.DoubleRef;

/**
 * 焱铠有15%自身最大生命值可抵消伤害的20%,破碎时反弹当前伤害的35%，普攻击碎则提升至60%，反弹伤害不超过目标生命值的20%
 */
public class 焱铠BH extends 护盾BH{

	private double 技能系数;
	private double 普攻系数;
	private double 最大系数;

	//技能系数=3500&普攻系数=6000&最大系数=2000
	@Override
	public void parse(String code) {
		super.parse(code);
		PlayCfgArgs args = new PlayCfgArgs(code);
		技能系数 = args.getWDouble("技能系数",0d);
		普攻系数 = args.getWDouble("普攻系数",0d);
		最大系数 = args.getWDouble("最大系数",0d);
	}

	@Override
	public double handleAbsorb(ActionCtx action, DoubleRef doubleRef) {
		double absorb = super.handleAbsorb(action, doubleRef);
		if (action instanceof SkillActionCtx && absorb > 0 && !buff.valid) {
			SkillActionCtx skillAction = (SkillActionCtx) action;
			double coeff = 0d;
			if (skillAction.getSkill().cfg.row.type == GDSkill.Type.ACTIVE) {
				coeff = 技能系数;
			} else if (skillAction.getSkill().cfg.row.type == GDSkill.Type.ATTACK) {
				coeff = 普攻系数;
			}
			double damage = (doubleRef.v + absorb) * coeff;
			double max = skillAction.getActor().attr.total().hpTotal() * 最大系数;
			damage = Math.min(damage, max);
			skillAction.getActor().attr.buffHurt(action, buff.owner, damage);
		}
		return absorb;
	}
}
